#include "quadratics-core.h"
#include "quadratics-log.h"
#include <stdio.h>

int LOGGING_ENABLED = 0;
FILE *fp;

void printlog(char buffer[256]){
	if(LOGGING_ENABLED == 1){
		fprintf(fp,"%s \n", buffer);
	}

}
void toggleLog(){

	char c;
	int i;

	printf("Would you like to enable logging? (Y for yes, N for no):");
	c = getc(stdin);

	if((c =='Y')||(c=='y')){

		enableLog();
		printf("logging enabled.\n");
		fprintf(fp,"\n\n");
	}
	else
		printf("logging disabled.\n");


}
void enableLog(){

	fp = fopen("logfile", "a");

	if (fp == NULL) {
		fprintf(stderr, "Can't open log file\n");
		exit(1);
	}
	LOGGING_ENABLED = 1;
}
void closeLog(){
	if(LOGGING_ENABLED == 1)
		fclose(fp);
}
